<html>
<head>
<title>dff</title>
</head>
<body>
<script type="text/javascript" src="data.js"></script>
<script type="text/javascript">
function Base64() {
    // private property
    _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 
    // public method for encoding
    this.encode = function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        input = _utf8_encode(input);
        while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output +
            _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
            _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
        }
        return output;
    }
    // private method for UTF-8 encoding
    _utf8_encode = function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
 
        }
        return utftext;
    }
}


function dddddd(win) {
	var vv = win.document.getElementsByName("title");
	if(vv.length==0) localData.setItem("title",win.document.title);
	else localData.setItem("title",vv[0].content);

	alert(win.document.title);
	
	vv = win.document.getElementsByName("keywords");
	if(vv.length==0) localData.setItem("tag","");
	else localData.setItem("tag",vv[0].content);
	alert(vv[0]);
	
	vv = win.document.getElementsByName("description");
	if(vv.length==0) localData.setItem("intro", "");
	else localData.setItem("intro", vv[0].content);
	alert(vv[0].content);

    /*
	if(win.location.href) localData.setItem("url",win.location.href); //win.document.location.href��ʾûȨ��
	else localData.setItem("url","");
    */

    if(document.location.href) localData.setItem("url",document.location.href); //win.document.location.href��ʾûȨ��
    else localData.setItem("url","");
    
	
	if(win.videoId) localData.setItem("videoid",win.videoId);
	else localData.setItem("videoid","");
}



function dddddd_url(win) {
	var b = new Base64();
    b.encode("adfsdfa");
    query = "?value=";
    var vv = win.document.getElementsByName("title");
    if(vv.length==0){
    	if(win.document.title)
    		query += "&title="+b.encode(win.document.title);
    	else query += "&title=";
    }else{
    	 if(vv[0].content)
    		query += "&title="+b.encode(vv[0].content);
    	else query += "&title=";
    }

    //alert(localData.getItem("title"));
    
    vv = win.document.getElementsByName("keywords");
    if(vv.length==0){
    	query += "&tag=";
    }else{
    	query += "&tag="+b.encode(vv[0].content);
    }
    
    vv = win.document.getElementsByName("description");
    if(vv.length==0){
        query += "&intro=";
    }else{
        query += "&intro="+b.encode(vv[0].content);
    }

    /*
    if(win.location.href) localData.setItem("url",win.location.href); //win.document.location.href��ʾûȨ��
    else localData.setItem("url","");
    */


   
    if(win.document.URL) {
    	query += "&url="+b.encode(win.document.URL); //路奇，document.location.href是这个htm的地址即all.htm； win.document.URL和win.location.href(ie9无权限)才是调用脚本的网页地址
    }else {
    	query += "&url=";
    }
    
    
    if(win.videoId){
    	query += "&videoid="+b.encode(win.videoId);
    }else{
    	query += "&videoid=";
    }
	return query;
}

//dddddd(external.menuArguments);
//alert(external.menuArguments.document.title);
//window.open("dangqian.html");
//window.open("mainpage.html");
query = dddddd_url(external.menuArguments);
window.open("mainpage.html"+query);
//window.open("login.html","mainwin");
		
</script>
</body>
</html>